home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / CLASSSRC.PAK / GEOMETRS.CPP < prev    next >
C/C++ Source or Header  |  1997-05-06  |  3KB  |  152 lines

  1. //----------------------------------------------------------------------------
  2. // Borland WinSys Library
  3. // Copyright (c) 1993, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   5.5  $
  6. //
  7. // Implementation of persistent streaming for window system geometry classes
  8. //----------------------------------------------------------------------------
  9. #include <winsys/pch.h>
  10. #include <winsys/geometry.h>
  11.  
  12. #if defined(BI_NAMESPACE)
  13. namespace ClassLib {
  14. #endif
  15.  
  16. //----------------------------------------------------------------------------
  17. // TRect streaming
  18. //
  19.  
  20. //
  21. // Extracts the rectangle from a regular input stream.
  22. //
  23. istream& _WSYSFUNC
  24. operator >>(istream& is, TRect& r)
  25. {
  26.   _TCHAR ch;
  27.   return is >> ch >> r.left >> ch >> r.top >> ch
  28.             >> r.right >> ch >> r.bottom >> ch;
  29. }
  30.  
  31. //
  32. // Inserts the rectangle into a regular output stream.
  33. //
  34. ostream& _WSYSFUNC
  35. operator <<(ostream& os, const TRect& r)
  36. {
  37.   return os << '(' << r.left << ',' << r.top << '-'
  38.             << r.right << ',' << r.bottom << ')';
  39. }
  40.  
  41. //----------------------------------------------------------------------------
  42. // TPointL streaming
  43. //
  44.  
  45. //
  46. // Extract the point from a regular input stream.
  47. //
  48. istream& _WSYSFUNC
  49. operator >>(istream& is, TPointL& p)
  50. {
  51.   _TCHAR c;
  52.  
  53.   is >> c;
  54.  
  55.   long x;
  56.   is >> x;
  57.   p.x = x;
  58.  
  59.   is >> c;
  60.  
  61.   long y;
  62.   is >> y;
  63.   p.y = y;
  64.  
  65.   is >> c;
  66.  
  67.   return is;
  68. }
  69.  
  70. //
  71. // Insert the point into an output stream.
  72. //
  73. ostream& _WSYSFUNC
  74. operator <<(ostream& os, const TPointL& p)
  75. {
  76.   return os << '(' << p.x << ',' << p.y << ')';
  77. }
  78.  
  79. //----------------------------------------------------------------------------
  80. // TPointF streaming
  81. //
  82.  
  83. //
  84. // Extract a point from a regular input stream.
  85. //
  86. istream& _WSYSFUNC
  87. operator >>(istream& is, TPointF& p)
  88. {
  89.   _TCHAR c;
  90.   return is >> c >> p.x >> c >> p.y >> c;
  91. }
  92.  
  93. //
  94. // Insert a point into the output stream.
  95. //
  96. ostream& _WSYSFUNC
  97. operator <<(ostream& os, const TPointF& p)
  98. {
  99.   return os << '(' << p.x << ',' << p.y << ')';
  100. }
  101.  
  102.  
  103. //----------------------------------------------------------------------------
  104. // TPoint streaming
  105. //
  106.  
  107. //
  108. // Extract a point from an input stream.
  109. //
  110. istream& _WSYSFUNC
  111. operator >>(istream& is, TPoint& p)
  112. {
  113.   _TCHAR c;
  114.   return is >> c >> p.x >> c >> p.y >> c;
  115. }
  116.  
  117. //
  118. // Insert a point into an output stream.
  119. //
  120. ostream& _WSYSFUNC
  121. operator <<(ostream& os, const TPoint& p)
  122. {
  123.   return os << '(' << p.x << ',' << p.y << ')';
  124. }
  125.  
  126. //----------------------------------------------------------------------------
  127. // TSize streaming
  128. //
  129.  
  130. //
  131. // Extract a size from a regular input stream.
  132. //
  133. istream& _WSYSFUNC
  134. operator >>(istream& os, TSize& s)
  135. {
  136.   _TCHAR c;
  137.   return os >> c >> s.cx >> c >> s.cy >> c;
  138. }
  139.  
  140. //
  141. // Insert a size into an output stream.
  142. //
  143. ostream& _WSYSFUNC
  144. operator <<(ostream& os, const TSize& s)
  145. {
  146.   return os << '(' << s.cx << 'x' << s.cy << ')';
  147. }
  148.  
  149. #if defined(BI_NAMESPACE)
  150. } // namespace ClassLib
  151. #endif
  152.